package com.aweqy.porcelain.service.impl;

import com.aweqy.porcelain.entity.Literature;
import com.aweqy.porcelain.mapper.LiteratureMapper;
import com.aweqy.porcelain.service.LiteratureService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文献信息Service实现类
 */
@Service
public class LiteratureServiceImpl extends ServiceImpl<LiteratureMapper, Literature> implements LiteratureService {
    
    @Override
    public List<Literature> getLiteraturesByDynastyAndRegion(Integer dynastyId, Integer regionId) {
        QueryWrapper<Literature> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dynasty_id", dynastyId)
                   .eq("region_id", regionId)
                   .orderByDesc("created_at");
        return this.list(queryWrapper);
    }
    
    @Override
    public List<Literature> getLiteraturesByDynasty(Integer dynastyId) {
        QueryWrapper<Literature> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dynasty_id", dynastyId)
                   .orderByDesc("created_at");
        return this.list(queryWrapper);
    }
    
    @Override
    public List<Literature> getLiteraturesByRegion(Integer regionId) {
        QueryWrapper<Literature> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("region_id", regionId)
                   .orderByDesc("created_at");
        return this.list(queryWrapper);
    }
    
    @Override
    public Literature getLiteratureById(Integer literatureId) {
        return this.getById(literatureId);
    }
} 